home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Views / Standard Arrangements / GrowArrangement.cp next >
Text File  |  1997-06-28  |  4KB  |  179 lines

  1. // GrowArrangement.cp
  2.  
  3. #ifndef GrowArrangement_h
  4. #include "GrowArrangement.h"
  5. #endif
  6. #ifndef MinMax_h
  7. #include "MinMax.h"
  8. #endif
  9.  
  10. GrowArrangement::GrowArrangement( WindowFocus& focus )
  11.   : grow( focus )
  12.   {
  13.     RightLine().SetView( rightLine );
  14.     BottomLine().SetView( bottomLine );
  15.     Grow().SetView( grow );
  16.   }
  17.  
  18. void GrowArrangement::Arrange( Rectangle bounds )
  19.   {
  20.     Rectangle grow( bounds.right - barSize,
  21.                          bounds.bottom - barSize,
  22.                          bounds.right,
  23.                          bounds.bottom );
  24.  
  25.     Rectangle main( bounds.left,
  26.                          bounds.top,
  27.                          grow.left,
  28.                          grow.top );
  29.     
  30.     Rectangle rightLine( grow.left,
  31.                                 bounds.top,
  32.                                 grow.left + 1,
  33.                                 grow.top );
  34.     
  35.     Rectangle rightBar( rightLine.right,
  36.                               bounds.top,
  37.                               bounds.right,
  38.                               grow.top );
  39.     
  40.     Rectangle bottomLine( bounds.left,
  41.                                  grow.top,
  42.                                  grow.left,
  43.                                  grow.top + 1 );
  44.     
  45.     Rectangle bottomBar( bounds.left,
  46.                                 bottomLine.bottom,
  47.                                 grow.left,
  48.                                 bounds.bottom );
  49.     
  50.     Main().SetBounds( main );
  51.     Right().SetBounds( rightBar );
  52.     Bottom().SetBounds( bottomBar );
  53.     RightLine().SetBounds( rightLine );
  54.     BottomLine().SetBounds( bottomLine );
  55.     Grow().SetBounds( grow );
  56.   }
  57.  
  58. uint16 GrowArrangement::MinimumHeight() const
  59.   {
  60.     uint16 size = Max( Main().Size().MinimumHeight(),
  61.                              Right().Size().MinimumHeight() );
  62.     
  63.     Assert( size <= maxint16 - barSize );
  64.     
  65.     return size + barSize;
  66.   }
  67.  
  68. uint16 GrowArrangement::MinimumWidth() const
  69.   {
  70.     uint16 size = Max( Main().Size().MinimumWidth(),
  71.                              Bottom().Size().MinimumWidth() );
  72.     
  73.     Assert( size <= maxint16 - barSize );
  74.     
  75.     return size + barSize;
  76.   }
  77.  
  78. uint16 GrowArrangement::MaximumHeight() const
  79.   {
  80.     uint16 size = Min( Main().Size().MaximumHeight(),
  81.                              Right().Size().MaximumHeight() );
  82.     
  83.     if ( size >= maxint16 - barSize )
  84.         return maxint16;
  85.     
  86.     return size + barSize;
  87.   }
  88.  
  89. uint16 GrowArrangement::MaximumWidth() const
  90.   {
  91.     uint16 size = Min( Main().Size().MaximumWidth(),
  92.                              Bottom().Size().MaximumWidth() );
  93.     
  94.     if ( size >= maxint16 - barSize )
  95.         return maxint16;
  96.     
  97.     return size + barSize;
  98.   }
  99.  
  100. uint16 GrowArrangement::ReasonableHeight() const
  101.   {
  102.     uint16 size = Max( Main().Size().ReasonableHeight(),
  103.                              Right().Size().ReasonableHeight() );
  104.     
  105.     Assert( size <= maxint16 - barSize );
  106.     
  107.     return size + barSize;
  108.   }
  109.  
  110. uint16 GrowArrangement::ReasonableWidth() const
  111.   {
  112.     uint16 size = Max( Main().Size().ReasonableWidth(),
  113.                              Bottom().Size().ReasonableWidth() );
  114.     
  115.     Assert( size <= maxint16 - barSize );
  116.     
  117.     return size + barSize;
  118.   }
  119.  
  120. uint16 GrowArrangement::BestHeight() const
  121.   {
  122.     uint16 size = Main().Size().BestHeight();
  123.     
  124.     size = Min( size, Right().Size().MaximumHeight() );
  125.     size = Max( size, Right().Size().MinimumHeight() );
  126.     
  127.     Assert( size <= maxint16 - barSize );
  128.     
  129.     return size + barSize;
  130.   }
  131.  
  132. uint16 GrowArrangement::BestHeight( uint16 bound ) const
  133.   {
  134.     if ( bound <= barSize )
  135.         return bound;
  136.     
  137.     bound -= barSize;
  138.  
  139.     uint16 size = Main().Size().BestHeight( bound );
  140.     
  141.     size = Min( size, Right().Size().MaximumHeight() );
  142.     size = Max( size, Right().Size().MinimumHeight() );
  143.     size = Min( size, bound );
  144.     
  145.     Assert( size <= maxint16 - barSize );
  146.     
  147.     return size + barSize;
  148.   }
  149.  
  150. uint16 GrowArrangement::BestWidth() const
  151.   {
  152.     uint16 size = Main().Size().BestWidth();
  153.     
  154.     size = Min( size, Bottom().Size().MaximumWidth() );
  155.     size = Max( size, Bottom().Size().MinimumWidth() );
  156.     
  157.     Assert( size <= maxint16 - barSize );
  158.     
  159.     return size + barSize;
  160.   }
  161.  
  162. uint16 GrowArrangement::BestWidth( uint16 bound ) const
  163.   {
  164.     if ( bound <= barSize )
  165.         return bound;
  166.     
  167.     bound -= barSize;
  168.     
  169.     uint16 size = Main().Size().BestWidth( bound );
  170.     
  171.     size = Min( size, Bottom().Size().MaximumWidth() );
  172.     size = Max( size, Bottom().Size().MinimumWidth() );
  173.     size = Min( size, bound );
  174.     
  175.     Assert( size <= maxint16 - barSize );
  176.     
  177.     return size + barSize;
  178.   }
  179.